<template>
  <a-row :gutter="[20, 0]" class="mb-3 leading-8">
    <a-col :span="6" v-if="zpDataFlag">
      <label class="w-[8em] inline-block text-right">应考人数：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.bkksCount === null ? '--' : kmSummary.bkksCount }}
      </span>
    </a-col>
    <a-col :span="6" v-if="zpDataFlag">
      <label class="w-[8em] inline-block text-right">实考人数：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.skCount === null ? '--' : kmSummary.skCount }}
      </span>
    </a-col>
    <a-col :span="6" v-if="!zpDataFlag">
      <label class="w-[8em] inline-block text-right">试评试卷份数：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ !kmSummary.sjsprs && kmSummary.sjsprs != 0 ? '--' : kmSummary.sjsprs }}
      </span>
    </a-col>
    <a-col :span="6" v-if="zpDataFlag">
      <label class="w-[8em] inline-block text-right">缺考人数：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.qkCount === null ? '--' : kmSummary.qkCount }}
      </span>
    </a-col>
    <a-col :span="6">
      <label class="w-[8em] inline-block text-right">0分人数：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.lfrs === null ? '--' : kmSummary.lfrs }}
      </span>
    </a-col>
    <a-col :span="6">
      <label class="w-[8em] inline-block text-right">平均分：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.pjf === null ? '--' : kmSummary.pjf }}
      </span>
    </a-col>
    <a-col :span="6">
      <label class="w-[8em] inline-block text-right">最高分：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.zgf === null ? '--' : kmSummary.zgf }}
      </span>
    </a-col>
    <a-col :span="6">
      <label class="w-[8em] inline-block text-right">标准分差：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.bzc === null ? '--' : kmSummary.bzc }}
      </span>
    </a-col>
    <a-col :span="6">
      <label class="w-[8em] inline-block text-right">中位数：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.zws === null ? '--' : kmSummary.zws }}
      </span>
    </a-col>
    <a-col :span="6">
      <label class="w-[8em] inline-block text-right">区分度：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ kmSummary.qfd === null ? '--' : kmSummary.qfd }}
      </span>
    </a-col>
    <a-col :span="6">
      <label class="w-[8em] inline-block text-right">及格率：</label>
      <span
        class="w-1/2 text-center h-full inline-block border-[rgb(229 220 220)] border-b-3 border-double"
      >
        {{ typeof kmSummary.jgl === 'number' ? `${(kmSummary.jgl * 100).toFixed(2)}%` : '--' }}
      </span>
    </a-col>
  </a-row>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import { getcommonKmSummarySimple } from '/@/api/teacher'
const kmSummary = ref<any>({})
const props = defineProps({
  zpDataFlag: {
    type: Boolean,
    default: false,
  },
  kmdm: {
    type: String,
    default: '',
  },
  updeatObjTime: {
    type: Number,
    default: 0,
  },
})

watch(
  [() => props.kmdm, () => props.zpDataFlag, () => props.updeatObjTime],
  async () => {
    kmSummary.value = {
      bkksCount: '--',
      qkCount: '--',
      skCount: '--',
      lfrs: '--',
      pjf: '--',
      zgf: '--',
      bzc: '--',
      zws: '--',
      qfd: '--',
      jgl: '--',
    }
    if (!props.kmdm) return
    const { data, code } = await getcommonKmSummarySimple({
      kmdm: props.kmdm,
      zpDataFlag: props.zpDataFlag,
    })
    if (code === 200) {
      kmSummary.value = data
    }
  },
  {
    immediate: true,
  }
)
</script>
